--[[/**
-- * 
 * 疯魔状态
-- *
-- */]]

---@class BuffEffect215100 : BaseBuffEffect
BuffEffect215100 = ClientFight.CreateClass("BuffEffect215100", ClientFight.BaseBuffEffect)
local t = BuffEffect215100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
    local damageRatio1 = buff.buffBean.f_BuffEffectValue[1];
    local damageRatio2 = buff.buffBean.f_BuffEffectValue[2];
    local damageRatio3 = buff.buffBean.f_BuffEffectValue[3];
    local fightResult =  parameters[3];
    local source = buff.source;
    local target =  parameters[1];
    local maxHp1 = FighterAttributeManager.getFightAttr(source, FighterAttributeEnum.HP.id);
    local maxHp2 = FighterAttributeManager.getFightAttr(target, FighterAttributeEnum.HP.id);
    local atk = FighterAttributeManager.getFightAttr(source, FighterAttributeEnum.ATK.id);
    local damage1 = calcRatio(maxHp1, damageRatio1);
    local damage2 = calcRatio(maxHp2, damageRatio2);
    local damage3 = calcRatio(atk, damageRatio3);
    local targetDamage = Math.min(damage2, damage3);

    DamageManager.setFighterHp(fight, source, source, null, DamageResultTypeEnum.NORMAL, -damage1,
            source.hp - damage1, true, true, true,false);

    fight.log("疯魔[{}]--攻击者maxHp：{}，疯魔伤害：{}", buff.modelId, maxHp1, damage1);
    fight.log("疯魔[{}]--受击者maxHp：{}，疯魔伤害：{}，原始伤害：{}", buff.modelId, maxHp2, targetDamage, fightResult.damage);

    fightResult.setDamage(targetDamage + fightResult.damage);

    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()